<%@ page language="java"  import="java.sql.*" pageEncoding="UTF-8" %>
<%@ include file="db.jsp"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <table align="center">
        <caption>欢迎给教师投票</caption>
        <tr bgcolor="white">
            <td>编号</td>
            <td>姓名</td>
            <td>得票数</td>
            <td>投票</td>
        </tr>
        <%
            Connection connection = getConnection();
            Statement statement = connection.createStatement();
            String sql="SELECT TEACHERNO,TEACHERNAME,VOTE FROM T_VOTE;";
            ResultSet resultSet = statement.executeQuery(sql);
            while (resultSet.next()){
                String teacherno = resultSet.getString("TEACHERNO");
                String teachername = resultSet.getString("TEACHERNAME");
                int vote = resultSet.getInt("VOTE");
        %>
        <tr bgcolor="#ffc0cb">
            <td><%=teacherno%></td>
            <td><%=teachername%></td>
            <td><img src="img/bar.jpg" width="<%=vote%>" height="9" <%=vote%>></td>
            <td><a href="vote.jsp?teacherno=<%=teacherno%>">投票</a></td>
        </tr>
        <%
            }
            statement.close();
            connection.close();
        %>
    </table>

</body>
</html>
